﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/admincp.Master" AutoEventWireup="true" CodeBehind="OrderStatictis.aspx.cs" Inherits="VINETLIFE.AdminCP.OrderStatictis" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {

            $('input[type=radio]').on("click", function () {
                if (this.value == 'rdSearchDate') {
                    $('#dthsearchdate').css("display", "block");
                    $('#dthfromdate').css("display", "none");
                }
                else if (this.value == 'rdFromDate') {
                    $('#dthsearchdate').css("display", "none");
                    $('#dthfromdate').css("display", "block");
                }
            });
        })
        function SelectAllCheckboxes(spanChk) {

            // Added as ASPX uses SPAN for checkbox
            var oItem = spanChk.children;
            var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0];
            xState = theBox.checked;
            elm = theBox.form.elements;

            for (i = 0; i < elm.length; i++)
                if (elm[i].type == "checkbox" &&
                      elm[i].id != theBox.id) {
                    //elm[i].click();
                    if (elm[i].checked != xState)
                        elm[i].click();
                    //elm[i].checked=xState;
                }
        }
    </script>
    <style type="text/css">
    
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Label runat="server" ID="lblX"></asp:Label>
    <div class="tranhis-search-wrap">
        <div class="tranhis-search-inner-right">
            <div class="tranhis-search-inner-type">
                <span class="tranhis-lable-content">Username đại lý</span>
                <span class="tranhis-lable-contentr">
                    <asp:DropDownList runat="server" ID="ddlCustomer" AppendDataBoundItems="true" DataValueField="id" DataTextField="UserName" CssClass="ddl-input">
                        <asp:ListItem Text=" .: Chọn toàn bộ :. " Value="0"></asp:ListItem>
                    </asp:DropDownList>
                </span>
            </div>
            <div class="tranhis-search-inner-date">
                <table class="tranhis-table">
                    <tr>
                        <td class="tranhist-tdl">
                            <span class="tranhis-lable-content">Chọn thời gian        
                            </span>
                            <span class="tranhis-lable-contentr">
                                <asp:RadioButton runat="server" ID="rdSearchDate" GroupName="grpPurchase" Text="" Checked="true" />Ngày chính xác
                                <asp:RadioButton runat="server" ID="rdFromDate" GroupName="grpPurchase" Text="" />Khoảng thời gian
                            </span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="tranhis-search-inner-date">
                <table class="tranhis-table">
                    <tr>
                        <td class="tranhist-tdr">
                            <div id="dthsearchdate" class="dth-searchdate">
                                <span class="tranhis-lable-date">Chọn ngày</span>
                                <asp:TextBox runat="server" ID="txtSearchDate" CssClass="dth-input"></asp:TextBox>
                                <cc1:CalendarExtender runat="server" ID="X" TargetControlID="txtSearchDate" Format="dd/MM/yyyy"></cc1:CalendarExtender>
                            </div>
                            <div id="dthfromdate" style="display: none;" class="dth-searchdate">
                                <div class="dth-search-from-date">
                                    <span class="tranhis-lable-date">Từ ngày</span>
                                    <asp:TextBox runat="server" ID="txtFromDate" CssClass="dth-input" Width="100px"></asp:TextBox>
                                    <cc1:CalendarExtender runat="server" ID="CalendarExtender1" TargetControlID="txtFromDate" Format="dd/MM/yyyy"></cc1:CalendarExtender>
                                </div>
                                <div class="dth-search-to-date">
                                    <span class="tranhis-lable-date">Tới ngày</span>
                                    <asp:TextBox runat="server" ID="txtToDate" CssClass="dth-input" Width="100px"></asp:TextBox>
                                    <cc1:CalendarExtender runat="server" ID="CalendarExtender2" TargetControlID="txtToDate" Format="dd/MM/yyyy"></cc1:CalendarExtender>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                    </tr>
                </table>
            </div>
            <div class="tranhis-search-inner-search">
                <asp:Button runat="server" ID="btnSearch" Style="float: right;" Text="Tìm kiếm" CssClass="button-gg-green" />
            </div>
        </div>
    </div>
    <div class="tranhis-search-wrap">
        <table>
            <tr>
                <td></td>
                <td>
                    <span style="float: left; margin: 0 10px 0 0; font-weight: bold;">Chọn loại báo cáo
                    </span>
                    <span style="float: left; margin: 0 10px 0 0; line-height: 18px;">
                        <asp:RadioButton runat="server" ID="rdbGeneral" GroupName="grpReport" Checked="true" />
                        Báo cáo tổng quát
                    <asp:RadioButton runat="server" ID="rdbDetail" GroupName="grpReport" />Báo cáo chi tiết
                    </span>
                </td>
            </tr>
            <tr>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <asp:Button runat="server" Text="Xuất báo cáo" CssClass="button-gg-green" ID="btnExport" OnClick="btnExport_Click" />
                    <asp:Button runat="server" Text="Xuất báo cáo và xử lý hoàn tất" CssClass="button-gg-green" ID="btnExportAndComplete" />
                    <asp:Button runat="server" Text="Xử lý hoàn tất" CssClass="button-gg-green" ID="btnComplete" />
                </td>
            </tr>
        </table>

    </div>
    <div class="tranhis-wrap">
        <h4>Danh sách giao dịch</h4>
        <asp:GridView ID="grvLogAccount" DataKeyNames="ID" runat="server" AutoGenerateColumns="False"
            PageSize="50" CssClass="tstyle2" Width="100%" PagerStyle-CssClass="pgr" AllowPaging="true"
            OnPageIndexChanging="grvLogAccount_PageIndexChanging">
            <Columns>
                <asp:TemplateField HeaderText="Select" ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Center">
                    <HeaderTemplate>
                        <input type="checkbox" id="chkAll" onclick="javascript: SelectAllCheckboxes(this);"
                            runat="server" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="#" ItemStyle-Width="30px" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <%# Container.DataItemIndex + 1 %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="CreatedDate" DataFormatString="{0:dd/MM/yyyy hh:mm tt}" HeaderText="Ngày giao dịch" ItemStyle-Width="120px" />
                <asp:BoundField DataField="ReceivedValue" HeaderText="Số tiền nhận" DataFormatString="{0:#,##} đ" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="OrderValue" HeaderText="Giá trị đơn hàng" DataFormatString="{0:#,##} đ" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="Username" HeaderText="Username" ItemStyle-Width="100px" />
                <asp:BoundField DataField="CustomerCode" HeaderText="Tài khoản Vinetlife" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center"/>
                <asp:BoundField DataField="InvoiceNumber" HeaderText="Mã đơn hàng" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center"></asp:BoundField>
                <asp:TemplateField HeaderText="Trạng thái" ItemStyle-Width="100px"  ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <%#SetStatus(Eval("Status"))%>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                <p>Chưa có giao dịch nào được thực hiện</p>
            </EmptyDataTemplate>
        </asp:GridView>
    </div>
</asp:Content>
